package exemplos;

import br.edu.fvs.principal.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.Toast;

public class ExemploSubMenu extends Activity {
	//
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.main);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		MenuItem item = menu.add(0, 0, 0, "Novo");
		item = menu.add(0, 1, 0, "Salvar");
		item = menu.add(0, 2, 0, "Excluir");

		SubMenu subMenu = menu.addSubMenu(0, 3, 0, "Outros");
		item = subMenu.add(0, 4, 0, "Pesquisar");
		item = subMenu.add(0, 5, 0, "Lipar");
		item = subMenu.add(0, 6, 0, "Sair");
		return true;
	}

	public boolean onMenuItemSelected(int featureId, MenuItem item) {
		switch (item.getItemId()) {
		case 0:
			Toast.makeText(this, "Novo!", Toast.LENGTH_SHORT).show();
			break;
		case 1:
			Toast.makeText(this, "Salvar!", Toast.LENGTH_SHORT).show();
			break;
		case 2:
			Toast.makeText(this, "Excluir!", Toast.LENGTH_SHORT).show();
		case 4:
			Toast.makeText(this, "Pesquisar!", Toast.LENGTH_SHORT).show();
			break;
		case 5:
			Toast.makeText(this, "Limpar", Toast.LENGTH_SHORT).show();
			break;
		case 6:
			Toast.makeText(this, "Sair!", Toast.LENGTH_SHORT).show();
			break;
		}
		return false;

	}
}
